namespace MapsTest.TestClasses
{
    using System;
    using Brjnk.Maps;

    /// <summary>
    /// </summary>
    public class TestScheduledAction : IScheduledAction
    {
        private Action<string> call;
        private string name;
        private Action<TimeSpan> updateProgress;
        private Action<TicksTime, TicksTime> reset;

        public TestScheduledAction(Action<string> call, Action<TimeSpan> updateProgress, Action<TicksTime, TicksTime> reset, string name)
        {
            this.call = call;
            this.name = name;
            this.updateProgress = updateProgress;
            this.reset = reset;
        }

        public TestScheduledAction(Action<string> call, string name)
            : this(call, null, null, name)
        { }

        public void Execute(TicksTime time)
        {
            call(name);
        }

        private bool progressRequired = false;

        public bool ProgressRequired
        {
            get { return progressRequired; }
            set { progressRequired = value; }
        }

        public string Name
        {
            get { return name; }
        }

        public void UpdateProgress(TimeSpan remainingTime)
        {
            if (updateProgress != null) updateProgress(remainingTime);
        }

        public void Reset(TicksTime startTime, TicksTime endTime)
        {
            if (reset != null) reset(startTime, endTime);
        }
    }
}